// API 统一导出

export * from './auth'
export * from './user'
export * from './category'
export * from './account'
export * from './system'

// 重新导出常用接口
export { http } from '@/utils/request'

// API 基础URL配置
export const API_BASE_URL = {
  development: '/api',
  production: 'https://api.accountmanage.com/api'
}

// 当前环境的API地址
export const getCurrentApiUrl = () => {
  return process.env.NODE_ENV === 'production'
    ? API_BASE_URL.production
    : API_BASE_URL.development
}

// 错误码定义
export const ERROR_CODES = {
  SUCCESS: 200,
  UNAUTHORIZED: 401,
  FORBIDDEN: 403,
  NOT_FOUND: 404,
  VALIDATION_ERROR: 422,
  RATE_LIMIT: 429,
  SERVER_ERROR: 500
} as const

// 常用的响应类型
export interface ApiResponse<T = any> {
  code: number
  message: string
  data: T
  timestamp: number
}

export interface PaginationResponse<T = any> {
  data: T[]
  total: number
  per_page: number
  current_page: number
  last_page: number
  from: number
  to: number
}

export interface ListResponse<T = any> {
  list: T[]
  total?: number
}

// 排序方向
export type SortDirection = 'asc' | 'desc'

// 通用查询参数
export interface CommonQueryParams {
  page?: number
  limit?: number
  sort?: string
  direction?: SortDirection
  keyword?: string
}

// 通用分页参数
export interface PaginationParams {
  page?: number
  limit?: number
}